import 'package:event_bus/event_bus.dart';
import 'package:flutter/material.dart';
import 'package:flutter_axrjc/datasource/network/request/network_service.dart';
import 'package:flutter_axrjc/routes.dart';
import 'package:flutter_axrjc/util/IsarUtil.dart';
import 'package:flutter_axrjc/util/log_util.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:logger/logger.dart';
import 'package:wakelock/wakelock.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await initIsar();
  await Wakelock.enable();
  runApp(const MyApp());
}

EventBus eventBus = EventBus();
final logger = Logger(
  output: AppConsoleOutput(),
);

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 812),
      minTextAdapt: true,
      splitScreenMode: true,
      child: GetMaterialApp(
        builder: EasyLoading.init(),
        title: '安信睿检测',
        debugShowCheckedModeBanner: false,
        initialBinding: BindingsBuilder(() {
          Get.put<NetworkService>(NetworkService());
        }),
        initialRoute: MainRoutes.main,
        getPages: MainRoutes.pages,
        theme: ThemeData(
            colorScheme:
                ColorScheme.fromSeed(seedColor: const Color(0xffF7D25D)),
            useMaterial3: true,
            dividerColor: Colors.white),
      ),
    );
  }
}
